/**
 * @Author: 健聪
 * @Description: 方法可选参数
 * @Date: 2024/1/12
 */
void main() {
  printPerson("李四");
  printPerson("李四",age:20);
  printPerson("李四",age:30,gender:"男");
  printPerson("李四",gender:"女");
  // printPerson(gender:"女",name:"李四");   //报错，可选参数必须跟在必选参数后面

  printPerson2("张三");
  printPerson2("张三",20);
  printPerson2("张三",20,"男");
  // printPerson2("张三","男");   // 位置不对
}
// 可选参数
printPerson(String name, {int? age, String? gender}) {
  print('name: $name, age: $age, gender: $gender');
}
// 位置可选参数
printPerson2(String name, [int? age, String? gender]) {
  print('name: $name, age: $age, gender: $gender');
}